#include "kfs.hpp"
#include <boost/shared_ptr.hpp>
#include <cstdlib>
#include <map>
#include <string>

class CacheInode
{
public:

    CacheInode();

    ~CacheInode();

    block_index_t blockNum;
    bool dirty;
    Inode inode;
    size_t referenceCount;
};

typedef std::map<std::string, boost::shared_ptr<CacheInode> > InodeCache;

class CacheRef
{
public:

    explicit CacheRef(kfs::Impl* impl, InodeCache::iterator elt)
    : elt(elt), impl(impl)
    {
        ++ elt->second->referenceCount;
    }

    ~CacheRef();

    void write();

    InodeCache::iterator elt;

    kfs::Impl* impl;
};
